package com.nullpointer.xchat.service;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.nullpointer.xchat.utils.Utils;

public class NetworkReceiver extends BroadcastReceiver {
	private OnNetworkListener listener;

	@Override
	public void onReceive(Context context, Intent intent) {
		boolean isConnect = Utils.isConnectingToInternet(context);
		if (isConnect) {
			// hideNotification();
			if (listener != null) {
				listener.onOnline();
			}
		} else {
			if (listener != null) {
				listener.onOffine();
			}
			// AnoChatSocket.getInstance(context).disconnect();
			// showNotification();
		}

	}

	public void setOnNetworkListener(OnNetworkListener listener) {
		this.listener = listener;
	}

	public interface OnNetworkListener {
		void onOnline();

		void onOffine();
	}
}
